From df2dc2ef9bcbba07d8566a8706a562fe1bcfd134 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 1 Jul 2015 12:30:06 -0700 Subject: [PATCH] Improved job pickup time stats for delayed jobs * The delay time should not count Bug: T102743 Change-Id: I9e8b1f33b65681fd9f4f667233bce280bf6f227d --- includes/jobqueue/Job.php | 8 ++++++++ includes/jobqueue/JobRunner.php | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php index f7ef8a9306..3e23391cdf 100644 --- a/includes/jobqueue/Job.php +++ b/includes/jobqueue/Job.php @@ -144,6 +144,14 @@ abstract class Job implements IJobSpecification { : null; } + /** + * @return int|null UNIX timestamp of when the job was runnable, or null + * @since 1.26 + */ + public function getReadyTimestamp() { + return $this->getReleaseTimestamp() ?: $this->getQueuedTimestamp(); + } + /** * Whether the queue should reject insertion of this job if a duplicate exists * diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 3dfffaeabb..3982134b6b 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -199,10 +199,10 @@ class JobRunner implements LoggerAwareInterface { $timeMsTotal += $timeMs; $profiler->scopedProfileOut( $psection ); - $queuedTs = $job->getQueuedTimestamp(); - if ( $queuedTs ) { + $readyTs = $job->getReadyTimestamp(); + if ( $readyTs ) { // Record time to run for the job type - $pickupDelay = $popTime - $queuedTs; + $pickupDelay = $popTime - $readyTs; $stats->timing( 'jobqueue.pickup_delay.all', $pickupDelay ); $stats->timing( "jobqueue.pickup_delay.$jType", $pickupDelay ); } -- 2.20.1